<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>可漾产品 - 可漾官网</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="keywords" content="可漾  可漾官网   可漾红豆薏米水  可漾五红汤  可漾红豆水  可漾绿豆水  可漾牛蒡茶  可漾产品  山东可漾饮料有限公司" />
    <meta http-equiv="description"
      content="山东可漾饮料有限公司在以红豆薏米水为代表的谷物饮品方面已经形成了完善的研发、生产和销售体系，并申请了红豆水萃取提纯技术专利，产品一经上市便热销全网。其中抖音、淘宝平台销售额在同类产品中遥遥领先。" />
    <meta name="keywords" content="可漾  可漾官网   可漾红豆薏米水  可漾五红汤  可漾红豆水  可漾绿豆水  可漾牛蒡茶  可漾产品  山东可漾饮料有限公司" />
    <meta name="description"
      content="山东可漾饮料有限公司在以红豆薏米水为代表的谷物饮品方面已经形成了完善的研发、生产和销售体系，并申请了红豆水萃取提纯技术专利，产品一经上市便热销全网。其中抖音、淘宝平台销售额在同类产品中遥遥领先。" />
    <meta name="renderer" content="webkit">
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
    <link rel="bookmark" href="../favicon.ico" />
    <meta name="viewport" content="user-scalable=yes, width=device-width, initial-scale=0.5">
    <link rel="stylesheet" href="../static/css/main.css">
    <link rel="stylesheet" href="../static/css/header.css">
    <link rel="stylesheet" href="../static/css/product.min.css">
    <link rel="stylesheet" href="../static/css/footer.min.css">
  </head>
  <header>
    <div class="nav-box">
      <div id="logo" class="fl">
        <a href="../index.html"><img src="../static/images/Logo.png" alt="可漾"></a>
      </div>
      <ul class="nav fl clear">
        <a href="../index.html" class="nav-item nav-item1">
          <span class="nav-span">首页</span>
        </a>
        <a href="./about.html" class="nav-item">
          <span class="nav-span">关于我们</span>
        </a>  
        <span class="nav-item-wrap">
          <a href="#" class="nav-item active">
            <span class="nav-span">可漾产品</span>
          </a>
          <ul class="nav-list nav-list-prod">
            <!-- <li class="nav-li">红豆薏米水</li>
            <li class="nav-li">绿豆水</li>
            <li class="nav-li">五红汤</li>
            <li class="nav-li">红豆水</li>
            <li class="nav-li">红豆牛蒡茶</li> -->
          </ul>
        </span>
        <span class="nav-item-wrap nav-item-wrap2">
          <a href="./brandnew.html" class="nav-item">
            <span class="nav-span">企业动态</span>
          </a>
          <ul class="nav-list nav-list2 nav-list-dynamic">
            <li class="nav-li">
              <a href="./brandnew.html">品牌新闻</a>
            </li>
            <li class="nav-li">
              <a href="./enterpriseactivity.html">企业活动</a>
            </li>
            <li class="nav-li">
              <a href="./wonderfulmoment.html">精彩瞬间</a>
            </li>
          </ul>
        </span>
        <a href="./join.html" class="nav-item">
          <span class="nav-span">加入我们</span>
        </a>  
      </ul>
    </div>
  </header>
  <main>
    <div class="banner">
      <img class="banner-preivew" src="" alt="">
    </div>
    <div class="thumb-box">
      <ul class="thumb-ul flex">
      </ul>
      <div class="prod-info-box">
        <h6 class="name"></h6>
        <p class="desc eq2" title=""></p>
      </div>
    </div>
  </main>
  <!-- 底部区域 -->
  <footer>
    <div class="footer flex">
      <ul class="link-box flex">
      <li>
        <h3>关于我们</h3>
        <p><a href="./about.html#about-box">企业介绍</a></p>
        <p><a href="./about.html#mission-box">企业使命</a></p>
        <p><a href="./about.html#roadmap">企业发展</a></p>
      </li>
      <li class="footer-prod-list">
      </li>
      <li>
        <h3>企业动态</h3>
        <p><a href="./brandnew.html">品牌新闻</a></p>
        <p><a href="./enterpriseactivity.html">企业活动</a></p>
        <p><a href="./wonderfulmoment.html">精彩瞬间</a></p>
      </li>
      <li>
        <h3>加入我们</h3>
        <p><a href="./join.html">未来展望</a></p>
        <p><a href="./join.html">招商加盟</a></p>
      </li>
    </ul>
    <ul class="addr-box">
      <h2>怕湿气，喝可漾</h2>
      <p>山东可漾饮料有限公司</p>
      <p>售后服务热线：4006279199</p>
      <p>地址：山东省潍坊市坊子区黄旗堡街办一马路</p>
      <ul class="feedback flex-start">
        <li class="qr">
          <img src="../static/images/qrcode.png" alt="">
          <span>关注微信公众号</span>
          <img class="qrcode-scan" src="../static/images/qrcode-scan.png" alt="">
        </li>
      </ul>
    </ul>
    </div>
    <div class="right"><a href="https://beian.miit.gov.cn/#/Integrated/index">鲁ICP备19040840号-1</a></div>
  </footer>
  <script src="../static/js/master.js"></script>
  <script src="../static/libs/jquery-1.10.1.min.js"></script>
  <script>
var baseUrl = 'http://guanwang.keyangyinliao.com/api';
$(function() {
  // 商品列表
  var prodListData = [];
  getProdList();
  function getProdList() {
    $.ajax({
      url: baseUrl + '/ad',
      type: 'get',
      dataType: 'json',
      success: function (res) {
        if (res.code !== 200) return;
        prodListData = res.data;
        
        initNavProds();
        initCurrentProd(prodListData);
      }
    })
  }

  // 初始化默认产品id
  function initCurrentProd(data) {
    var urlParam = window.location.search.substr(1),
      urlId = '';
    if (!urlParam) {
      // 先从url中获取产品id 若无id设置第一个为默认 
      window.location.href = window.location.href + '?id=' + data[0].id;
     $('.banner-preivew').attr('src', data[0].bannerImg);
    } else {
      // 根据url中id 设置对应产品banner图
      urlId = getUrlParam(urlParam, "id");
      $.each(data, function(i) {
        if (data[i].id == urlId) {
          $('.banner-preivew')
          .attr('src', data[i].large_img_url);
          $('.prod-info-box .name').text(data[i].title);
          $('.prod-info-box .desc').text(data[i].desc); 
          return true;
        }

        $('.thumb-li').each(function(j) {
          if ($(this).attr('data-id') == urlId) {
            $(this).addClass('active');
            return false;
          }
        })
      })
    }
  }

  function initNavProds() {
    var prodListHeadSubHtml = '',
      prodListHtml = '',
      footerProdListHtml = '<h3>可漾产品</h3>';

    $.each(prodListData, function(i) {
      prodListHeadSubHtml += '<li class="nav-li" data-id=' + prodListData[i].id + '>' + prodListData[i].title + '</li>'
    
      prodListHtml += '<li class="thumb-li pointer" data-id="' + prodListData[i].id + '" data-title="' + prodListData[i].title + '" data-desc="' + prodListData[i].desc + '" data-img="' + prodListData[i].large_img_url + '">' +
          '<img src="' + prodListData[i].thumbnail_img_url + '" alt="">' +
          '<p><span class="name">' + prodListData[i].title + '</span></p>' +
        '</li>';
    
      footerProdListHtml += '<p><a href="./product.html?id=' + prodListData[i].id + '">' + prodListData[i].title + '</a></p>';
    })

    $('.thumb-ul').append(prodListHtml);

    // 头部导航[产品]下的【子产品】导航
    $('.nav-list-prod').append(prodListHeadSubHtml);
    $('.nav-list-prod .nav-li').each(function(i) {
      $(this).click(function() {
        window.location.href = './product.html?id=' + $(this).attr('data-id');
      })
    })

    // 切换产品 同时切换对应描述
    $('.thumb-li').each(function(i) {
      $(this).click(function() {
        $('.banner-preivew')
        .attr('src', $(this).attr('data-img'))
        $('.prod-info-box .name').text($(this).attr('data-title'));
        $('.prod-info-box .desc').text($(this).attr('data-desc'));
        $(this).addClass('active').siblings('.thumb-li').removeClass('active');
      })
    })

    // footer里的产品信息
    $('.footer-prod-list').append(footerProdListHtml);
  }
})

// 从url中拿参数
    function getUrlParam(paramsString, key) {
      var value = '';
      var paramsArray = paramsString.split('&');
      for(var i=0;i<paramsArray.length;i++){
          var param = paramsArray[i].split("=");
          if(param[0] == key){
            value = decodeURIComponent(param[1])
            break;
          }
      }
      return value;
    }
  </script>
</html>